<script setup>
import { ref } from 'vue';

const count = ref(0);

const hRef = ref(null);
const getH1 = () => {
  console.log(hRef.value.innerText);
};

// 获取input
const inputRef = ref(null);
const getInput = () => {
  console.log(inputRef.value);
  inputRef.value.focus();
};
</script>

<template>
  <div>
    <h1 ref="hRef">{{ count }}</h1>
    <button @click="count++">count++</button>
    <button @click="getH1">获取h1的原生DOM</button>
    <!-- 关联原生DOM -->
    <input ref="inputRef" type="text" />
    <button @click="getInput">获取input并设置焦点</button>
  </div>
</template>
